package com.itic.hpp.user;

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itic.appbase.framework.Base.BaseCode;
import com.itic.appbase.framework.common.constants.DBConst;
import com.itic.appbase.framework.utils.DateHelper;
import com.itic.appbase.framework.utils.HttpRequestUtils;
import com.itic.appbase.framework.utils.RandomStringHelper;
import com.itic.system.user.code.persistence.model.HppUserCode;
import com.itic.system.user.code.service.HppUserCodeService;
import com.itic.system.vo.CarrageVo;
import com.itic.system.vo.PersonSetInVo;
import com.itic.system.vo.UserVo;
import com.itic.system.wx.persistence.model.Hppwx;
import com.itic.system.wx.service.HppwxService;
import com.itic.system.wx.token.persistence.model.HppWxtoken;
import com.itic.system.wx.token.service.HppWxtokenService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.itic.appbase.framework.common.constants.ResponseCode;
import com.itic.appbase.framework.utils.StringHelper;
import com.itic.appbase.framework.utils.WXconfigTypeVo;
import com.itic.appbase.framework.utils.WxUtils;
import com.itic.mobile.base.BaseMobile;
import com.itic.system.user.user.persistence.model.HppUser;
import com.itic.system.user.user.service.HppUserService;

@Controller
@RequestMapping(value = "/hpp/user")
public class UserInterface extends BaseMobile {

	@Autowired
	private HppUserCodeService hppUserCodeService;
	@Autowired
	private HppUserService hppUserService;
	@Autowired
	private HppwxService hppwxService;
	@Autowired
	private HppWxtokenService hppWxtokenService;

	// 返回通用属性黑名单
	// 返回属性黑名单
	private static String[] ignoreProperties = new String[] { "createUser", "isEffective", "updateTime", "orgCode" };

	@RequestMapping(value = "/param")
	@ResponseBody
	public Map<String, Object> param(String userId, PersonSetInVo vos, HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		try {
			PersonSetInVo vo = new PersonSetInVo();
			vo.setIdbPhoto("http://www.uhuijia.com.cn/images/welcome.png");
			vo.setIdentity("222405199210111123");
			vo.setIdentityType("sfz");
			vo.setIdExpireEtime(DateHelper.parseDate("2012-10-10"));
			vo.setIdfPhoto("http://www.uhuijia.com.cn/images/welcome.png");
			vo.setIdHeamimg("http://www.uhuijia.com.cn/images/welcome.png");
			vo.setLogo("http://www.uhuijia.com.cn/images/welcome.png");
			vo.setMail("437584323@qq.com");
			vo.setName("lib");
			vo.setStoreName("我的");
			vo.setUserId("1");
			resultMap.put(DATA, vo);
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "getinfo", e.toString(), "用户信息查询", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 个人资料修改
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/modify")
	@ResponseBody
	public Map<String, Object> modifyUserInfo(String userId,String headImg,String userName,String qrCode,
			String aboutMe,HttpServletRequest request,HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		String result = ResponseCode.SERVER_ERROR.getCode();
		try{
			if(StringUtils.isNotBlank(userId)){
				HppUser hppUser = hppUserService.get(userId);
				if (hppUser != null) {
					if(StringUtils.isNotBlank(headImg)){
						hppUser.setHeadImg(headImg);
					}
					if(StringUtils.isNotBlank(userName)){
						hppUser.setNickName(userName);
					}
					if(StringUtils.isNotBlank(qrCode)){
						hppUser.setQrCode(qrCode);
					}
					if(StringUtils.isNotBlank(aboutMe)){
						hppUser.setAboutMe(aboutMe);
					}
					result = hppUserService.edit(hppUser);
					if (ResponseCode.SUCCESS.getCode().equals(result)) {
						errorCode = SUCCESS_ERROR_CODE;
						errorMsg = SUCCESS_ERROR_MSG;
					}
				} else {
					errorCode = USER_ERROR_CODE;
					errorMsg = USER_ERROR_MSG;
				}
			}
		}catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "modify", e.toString(), "个人资料修改", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
		}
	/**
	 * 扫码二维码获取凭证
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/ticket")
	@ResponseBody
	public Map<String, Object> getticket(HttpServletRequest request,HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		String result = ResponseCode.SERVER_ERROR.getCode();
		try {
			Hppwx hppwx = hppwxService.getHppwxByType(WXconfigTypeVo.gzh.getType());
			String appId = null;
			String appSecret = null;
			if(hppwx != null){
				appId = hppwx.getAppId();
				appSecret = hppwx.getAppSecret();
				String access_token = hppWxtokenService.getHppWxtoken();
				Map<String, String> map = WxUtils.getTicket(access_token,appId,appSecret);
				String ticket = null;
				String accessToken = null;
				if(map.size()>0){
					ticket = map.get("ticket");
					resultMap.put(DATA, ticket);
					errorCode = SUCCESS_ERROR_CODE;
					errorMsg = SUCCESS_ERROR_MSG;
					accessToken = map.get("access_token");
					HppWxtoken hppWxtoken = new HppWxtoken();
					hppWxtoken.setAccessToken(accessToken);
					result = hppWxtokenService.addNew(hppWxtoken);
				}else{
					errorCode = TICKET_ERROR_CODE;
					errorMsg = TICKET_ERROR_MSG;
				}
			}else{
				errorCode = WX_CONFIG_ERROR_CODE;
				errorMsg = WX_CONFIG_ERROR_MSG;
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "ticket", e.toString(), "扫码二维码获取凭证", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 *  修改用户基本资料
	 * @param userId
	 * @param storeName
	 * @param logo
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/edit")
	@ResponseBody
	public Map<String, Object> edit(String userId, String storeName, String logo, HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		String result = ResponseCode.SERVER_ERROR.getCode();
		try {
			if (StringUtils.isNotBlank(userId)) {
				HppUser hppUser = hppUserService.get(userId);
				if (hppUser != null) {
					if (StringHelper.isNotBlank(storeName)) {
						hppUser.setStoreName(storeName);
					}
					if (StringHelper.isNotBlank(logo)) {
						hppUser.setLogo(logo);
					}
					result = hppUserService.editUserInfo(hppUser);
					if (ResponseCode.SUCCESS.getCode().equals(result)) {
						errorCode = SUCCESS_ERROR_CODE;
						errorMsg = SUCCESS_ERROR_MSG;
					}
				} else {
					errorCode = USER_ERROR_CODE;
					errorMsg = USER_ERROR_MSG;
				}
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "edit", e.toString(), "修改用户基本资料", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 个人入住和编辑
	 * @param vos
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/psetEdit")
	@ResponseBody
	public Map<String, Object> psetEdit(@RequestBody PersonSetInVo vos, HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		String result = ResponseCode.SERVER_ERROR.getCode();
		try {
			if (vos != null) {
				result = hppUserService.psetEdit(vos);
				if (ResponseCode.SUCCESS.getCode().equals(result)) {
					errorCode = SUCCESS_ERROR_CODE;
					errorMsg = SUCCESS_ERROR_MSG;
				}
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "getinfo", e.toString(), "个人入住", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	// 个人认证

	/**
	 * 查询用户
	 * @param userId
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/getinfo")
	@ResponseBody
	public Map<String, Object> getinfo(String userId, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		try {
			if (StringHelper.isNotBlank(userId)) {
				UserVo vo = hppUserService.getUserInfo(userId);
				errorCode = SUCCESS_ERROR_CODE;
				errorMsg = SUCCESS_ERROR_MSG;
				resultMap.put(DATA, vo);
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "getinfo", e.toString(), "用户信息查询", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 扫描二维码
	 * @param code
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/getQR")
	@ResponseBody
	public Map<String, Object> getQR(String code, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		try {
			Hppwx hppwx = hppwxService.getHppwxByType(WXconfigTypeVo.kf.getType());
			if(hppwx != null){
				if (StringHelper.isNotBlank(code)) {
					String openId = WxUtils.getopenId(code,hppwx.getAppId(),hppwx.getAppSecret());
					UserVo vo = hppUserService.getUser(openId);
					errorCode = SUCCESS_ERROR_CODE;
					errorMsg = SUCCESS_ERROR_MSG;
					resultMap.put(DATA, vo);
				}
			}else{
				errorCode = WX_CONFIG_ERROR_CODE;
				errorMsg = WX_CONFIG_ERROR_MSG;
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "getQR", e.toString(), "扫描二维码", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 新增用户
	 * @param code
	 * @param phone
	 * @param phonecode
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/reg")
	@ResponseBody
	public Map<String, Object> reg(String code, String phone, String phonecode, HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		String result = ResponseCode.SERVER_ERROR.getCode();
		try {
			Hppwx hppwx = hppwxService.getHppwxByType(WXconfigTypeVo.kf.getType());
			if(hppwx != null){
				if (StringHelper.isNoneBlank(code, phone, phonecode)) {
					if (isEffectiveCode(phone, phonecode)) {
						result = hppUserService.regNewUser(code, phone,hppwx.getAppId(),hppwx.getAppSecret());
						if (ResponseCode.SUCCESS.getCode().equals(result)) {
							errorCode = SUCCESS_ERROR_CODE;
							errorMsg = SUCCESS_ERROR_MSG;
						}
					} else {
						errorCode = PHONE_CODE_ERROR_CODE;
						errorMsg = PHONE_REGED_ERROR_MSG;
					}
				}
			}else{
				errorCode = WX_CONFIG_ERROR_CODE;
				errorMsg = WX_CONFIG_ERROR_MSG;
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "reg", e.toString(), "新用户注册", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 账号密码登陆
	 *
	 * @param phone
	 * @param pwd
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/login")
	@ResponseBody
	public Map<String, Object> login(String phone, String pwd, HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		String result = ResponseCode.SERVER_ERROR.getCode();
		try {
			if (StringHelper.isNoneBlank(phone, pwd)) {
				result = hppUserService.login(phone, pwd);
				if (ResponseCode.SUCCESS.getCode().equals(result)) {
					errorCode = SUCCESS_ERROR_CODE;
					errorMsg = SUCCESS_ERROR_MSG;
				} else {
					errorCode = USER_ERROR_CODE;
					errorMsg = USER_ERROR_MSG;
				}
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "login", e.toString(), "账号密码登陆", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 忘记密码修改密码
	 *
	 * @param phone
	 * @param code
	 * @param newPwd
	 * @param conPwd
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/updatePwd")
	@ResponseBody
	public Map<String, Object> updatePwd(String phone, String code, String newPwd, String conPwd,
			HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		try {
			if (StringUtils.isNoneBlank(phone, code, newPwd, conPwd)) {
				if (isEffectiveCode(phone, code) && newPwd.equals(conPwd)) {
					Integer result = hppUserService.updatePwd(phone, newPwd);
					if (result == 1) {
						errorCode = SUCCESS_ERROR_CODE;
						errorMsg = SUCCESS_ERROR_MSG;
					}
				} else {
					if (!isEffectiveCode(phone, code)) {
						errorCode = PHONE_CODE_ERROR_CODE;
						errorMsg = PHONE_REGED_ERROR_MSG;
					} else {
						errorCode = PWDMATCH_CODE_ERROR_CODE;
						errorMsg = PWDMATCH_CODE_ERROR_MSG;
					}
				}
			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "updatePwd", e.toString(), "忘记密码", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * APP手机发送验证码
	 *
	 * @return
	 */
	@RequestMapping(value = "/code")
	@ResponseBody
	public Map<String, Object> code(HttpServletRequest request, HttpServletResponse response, String phone) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		String errorCode = PARAM_ERROR_CODE;
		String errorMsg = PARAM_ERROR_MSG;
		try {
			if (StringHelper.isNotBlank(phone)) {
				String isOpenPhone = sysSettingService.getByKey("IS_OPEN_PHONE_CODE");
				if (StringHelper.isNotBlank(isOpenPhone) && DBConst.TRUE.equals(isOpenPhone)) {
					HppUserCode phoneCode = new HppUserCode();
					phoneCode.setPhone(phone);
					phoneCode.setCode("123456");
					phoneCode.setExpiredTime(getExpiredTimeCode(new Date()));
					hppUserCodeService.add(phoneCode);
					errorCode = SUCCESS_ERROR_CODE;
					errorMsg = SUCCESS_ERROR_MSG;
				} else {
					// 发送验证码
					String randomNumStr = RandomStringHelper.randomNumStr(6);

					HppUserCode phoneCode = new HppUserCode();
					phoneCode.setPhone(phone);
					phoneCode.setCode(randomNumStr);
					phoneCode.setExpiredTime(getExpiredTimeCode(new Date()));

					String temp = hppUserCodeService.add(phoneCode);
					String sendMassage = sendMassageCx(phone, randomNumStr);

					if (SUCCESS.equals(temp) && SUCCESS.equals(sendMassage)) {
						errorCode = SUCCESS_ERROR_CODE;
						errorMsg = SUCCESS_ERROR_MSG;
					} else {
						errorCode = FAIL_CODE_ERROR_CODE;
						errorMsg = FAIL_CODE_ERROR_MSG;
					}
				}

			}
		} catch (Exception e) {
			errorCode = SERVER_ERROR_CODE;
			errorMsg = SERVER_ERROR_MSG;
			logException("UserInterface", "code", e.toString(), "APP手机发送验证码", e);
		}
		resultMap.put(CODE, errorCode);
		resultMap.put(MSG, errorMsg);
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * hpp用户认证接口
	 *
	 * @param openId
	 *            微信的openId
	 * @param phone
	 *            手机号
	 * @param nickName
	 *            昵称
	 * @param avatarUrl
	 *            头像
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/auth")
	@ResponseBody
	public Map<String, Object> authOpenId(String openId, String phone, String nickName, String avatarUrl,
			HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			// 效验参数
			if (StringHelper.isNoneBlank(openId, nickName)) {
				// 小程序认证
				HppUser user = this.hppUserService.authUser(openId, phone, nickName, avatarUrl);
				// 判断授权是否成功
				if (user != null) {
					UserVo userVo = new UserVo(user.getId(), user.getPhone(), user.getOpenId(), user.getNickName(),
							user.getHeadImg(), user.getQrCode(), user.getAboutMe(), user.getMoney(), user.getState());
					resultMap.put(BaseCode.DATA, userVo);
					resultMap.put(BaseCode.CODE, BaseCode.SUCCESS_ERROR_CODE);
					resultMap.put(BaseCode.MSG, BaseCode.SUCCESS_ERROR_MSG);
				} else {
					// 失败返回授权失败
					resultMap.put(BaseCode.CODE, BaseCode.HPP_AUTH_USER_FAIL_CODE);
					resultMap.put(BaseCode.MSG, BaseCode.HPP_AUTH_USER_FAIL_MSG);
				}
			} else {
				resultMap.put(BaseCode.CODE, BaseCode.PARAM_ERROR_CODE);
				resultMap.put(BaseCode.MSG, BaseCode.PARAM_ERROR_MSG);
			}
		} catch (Exception e) {
			resultMap.put(BaseCode.CODE, BaseCode.SERVER_ERROR_CODE);
			resultMap.put(BaseCode.MSG, BaseCode.SERVER_ERROR_MSG);
			logException("UserInterface", "authOpenId", e.toString(), "hpp用户openId认证", e);
		}
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 用户个人中心页面数据
	 * @param userId
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/personalCenter")
	@ResponseBody
	public Map<String, Object> personalCenter(String userId, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			// 效验参数
			if (StringHelper.isNoneBlank(userId)) {
				resultMap = this.hppUserService.personalCenter(userId);
			} else {
				resultMap.put(BaseCode.CODE, BaseCode.PARAM_ERROR_CODE);
				resultMap.put(BaseCode.MSG, BaseCode.PARAM_ERROR_MSG);
			}
		} catch (Exception e) {
			resultMap.put(BaseCode.CODE, BaseCode.SERVER_ERROR_CODE);
			resultMap.put(BaseCode.MSG, BaseCode.SERVER_ERROR_MSG);
			logException("UserInterface", "personalCenter", e.toString(), "个人中心", e);
		}
		isCrrossDomain(response);
		return resultMap;
	}

	/**
	 * 通过openId查询用户信息
	 * @param openId
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/userInfoByOpenId")
	@ResponseBody
	public Map<String, Object> userInfoByOpenId(String openId, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			// 效验参数
			if (StringHelper.isNoneBlank(openId)) {
				UserVo userVo = this.hppUserService.getUser(openId);
				resultMap.put(BaseCode.DATA, userVo);
				resultMap.put(BaseCode.CODE, BaseCode.SUCCESS_ERROR_CODE);
				resultMap.put(BaseCode.MSG, BaseCode.SUCCESS_ERROR_MSG);
			} else {
				resultMap.put(BaseCode.CODE, BaseCode.PARAM_ERROR_CODE);
				resultMap.put(BaseCode.MSG, BaseCode.PARAM_ERROR_MSG);
			}
		} catch (Exception e) {
			resultMap.put(BaseCode.CODE, BaseCode.SERVER_ERROR_CODE);
			resultMap.put(BaseCode.MSG, BaseCode.SERVER_ERROR_MSG);
			logException("UserInterface", "personalCenter", e.toString(), "通过openId查询用户信息", e);
		}
		return resultMap;
	}

	/**
	 * 查询用户余额
	 * @param userId
	 * @return
	 */
	@RequestMapping(value = "/money")
	@ResponseBody
	public Map<String, Object> userMoney(String userId) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			// 效验参数
			if (StringHelper.isNoneBlank(userId)) {
				HppUser user = this.hppUserService.get(userId);
				resultMap.put(BaseCode.DATA, user.getMoney());
				resultMap.put(BaseCode.CODE, BaseCode.SUCCESS_ERROR_CODE);
				resultMap.put(BaseCode.MSG, BaseCode.SUCCESS_ERROR_MSG);
			} else {
				resultMap.put(BaseCode.CODE, BaseCode.PARAM_ERROR_CODE);
				resultMap.put(BaseCode.MSG, BaseCode.PARAM_ERROR_MSG);
			}
		} catch (Exception e) {
			resultMap.put(BaseCode.CODE, BaseCode.SERVER_ERROR_CODE);
			resultMap.put(BaseCode.MSG, BaseCode.SERVER_ERROR_MSG);
			logException("UserInterface", "money", e.toString(), "查询用户余额接口", e);
		}
		return resultMap;
	}




}
